{% extends "nav.html" %}
{% block little %}存储-光交信息{% endblock %}
{% block content %}
    <!-- Main Content -->
    <div class="container-fluid">
        <div class="side-body">
            <div class="page-title">
                <span class="title">光交信息查看</span>
                <div class="description">网服所有光交信息查看</div>
            </div>
            <div class="row">
                <div class="col-xs-12">
                    <div class="card">
                        <div class="card-header">

                            <div class="card-title">
                                <div class="title">光交列表</div>
                            </div>
                        </div>
                        <div class="card-body">
                            <table class="datatable table table-striped table-hover" cellspacing="0" width="100%">
                                <thead>
                                <tr>
                                    <th>厂商</th>
                                    <th>型号</th>
                                    <th>sn</th>
                                    <th>固件微码</th>
                                    <th>管理IP</th>
                                    <th>账号</th>
                                    <th>机房位置</th>
                                    <th>domain</th>
                                    <th>online端口</th>
                                    <th>可用端口</th>
                                    <th>无模块</th>
{#                                    <th>其他端口</th>#}
                                    <th>设备位置</th>
                                    {% if perms.San_port %}
                                    <th>操作</th>
                                    {% endif %}
                                </tr>
                                </thead>
                                <tfoot>
                                <tr>
                                    <th>厂商</th>
                                    <th>型号</th>
                                    <th>sn</th>
                                    <th>固件微码</th>
                                    <th>管理IP/th>
                                    <th>账号</th>
                                    <th>机房位置</th>
                                    <th>domain</th>
                                    <th>online端口</th>
                                    <th>可用端口</th>
                                    <th>无模块</th>
{#                                    <th>其他端口</th>#}
                                    <th>设备位置</th>
                                    {% if perms.San_port %}
                                    <th>操作</th>
                                    {% endif %}
                                </tr>
                                </tfoot>
                                <tbody>
                                {% for i in data %}
                                    <tr>
                                        <td>{{ i.prodname }}</td>
                                        <td>{{ i.prodect }}</td>
                                        <td ><a href="{% url "sanmess" i.id %}" target="_blank">{{ i.sn }}</a></td>
                                        <td><a href="{% url "sanmess" i.id %}" target="_blank">{{ i.firmware }}</a></td>
                                        <td>{{ i.ip }}</td>
                                        <td>{{ i.user }}</td>
                                        <td>{{ i.jifangadress }}</td>
                                        <td>{{ i.domain }}</td>
                                        <td>{{ i.onlineport }}</td>
                                        <td>{{ i.availableport }}</td>
                                        <td>{{ i.nomodelport }}</td>
{#                                        <td>{{ i.otherport }}</td>#}
                                        <td>{{ i.position }}</td>
                                        {% if perms.San_port %}
                                        <td><a type="button" nid="{{ i.id }}" class="btn btn-info btn-xs san_sel_update" style="margin: 0px 0px;top: 0px;" >更  新</a>
                                            <a type="button" nid="{{ i.id }}" class="btn btn-danger btn-xs san_sel_delete" style="margin: 0px 0px;top: 0px;" >收  集</a>
                                        </td>
                                    {% endif %}
                                    </tr>
                                {% endfor %}
                                </tbody>
                            </table>
                            <div>
                                {% if perms.San_port %}
{#                                <button type="button" class="btn btn-primary" id="san_up">一键更新信息</button>#}
                                {% endif %}
                                <a href="{% url "sancompall" %}" target="_blank" type="button" class="btn btn-primary" id="san_xunjian">自动巡检</a>
                                {% if perms.San_port %}
{#                                <button type="button" class="btn btn-primary" id="san_bidui">选择性比对</button>#}
                                {% endif %}
                                {#                                  <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#san_update" id="san_up">一键更新信息</button>#}
                            </div>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </div>
{% endblock %}
{% block js %}
    <div class="modal fade" tabindex="-1" role="dialog" id="san_update">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title">更新光交信息</h4>
                </div>
                <div class="modal-body">
                    <p id="san_err">任务添加中,请等待&hellip;</p>
                    <div class="progress">
                        <div id="san_jindutiao" class="progress-bar progress-bar-striped active" role="progressbar" aria-valuenow="45" aria-valuemin="0" aria-valuemax="100" style="width: 100%">
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default st_close" data-dismiss="modal" id="ST_close">关闭</button>
                    {#                    <button type="button" class="btn btn-primary">Save changes</button>#}
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
    <script>
        $('#san_up').click(function () {
            $('#san_update').modal({backdrop: 'static', keyboard: false},'toggle')
            $("#ST_close").hide();

            $.ajax({
                url: "{% url "sanupdateall" %}",
                type: 'POST',
                data:"",
                success: function(data){
                    var obj = JSON.parse(data);
                    if(obj.status){
                        $("#san_err").text("任务添加成功");
                        $("#ST_close").show();
                        $("#san_jindutiao").hide();
                    }else{
                        $("#san_err").text(obj.error);
                        $("san_jindutiao").hide();
                        $("#ST_close").show();
                    };
                }
            })
        });
        $('.san_sel_update').click(function () {
            $('#san_update').modal({backdrop: 'static', keyboard: false},'toggle')
            $("#ST_close").hide();
            $("#san_jindutiao").show();
            var nid = $(this).attr("nid")
            console.log(nid)
            $.ajax({
                url: "{% url "san_sel_update_ajax" %}",
                type: 'POST',
                data:{"id":nid},
                success: function(data){
                    var obj = JSON.parse(data);
                    if(obj.status){
                        $("#san_err").text("任务添加成功");
                        $("#ST_close").show();
                        $("#san_jindutiao").hide();
                    }else{
                        $("#san_err").text("任务添加失败");
                        $("san_jindutiao").hide();
                        $("#ST_close").show();
                    };
                }
            })
        });
    </script>
{% endblock %}